package za.co.EYEWTKAH.jmsProjects.openJmsPlugin;

import java.util.Map;

import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;

import com.btmatthews.utils.monitor.Monitor;
import com.btmatthews.utils.monitor.Server;
import com.btmatthews.utils.monitor.ServerFactory;

@Mojo(name = "start")
public class OpenJmsStartPlugin extends OpenJmsRunPlugin {

    public void execute() throws MojoFailureException {

        // Create the server
        final ServerFactory factory = new OpenJmsServerFactory();
        final Server server = factory.createServer();

        // Configure the server

        final Map<String, Object> config = getServerConfig();
        for (final Map.Entry<String, Object> entry : config.entrySet()) {
            server.configure(entry.getKey(), entry.getValue(), this);
        }

        // Run the monitor

        final Monitor monitor = createMonitor();
        monitor.runMonitorDaemon(server, this, this);
    }

}
